package com.p2p.front.dal.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;

import com.p2p.base.dao.BaseMapper;
import com.p2p.base.page.PageVo;

/**
 * leiwen@yiqihao.com
 */
public interface UserLoanDao extends BaseMapper {

	@Select("select * from p2p_loan_info")
	List<Map<String,Object>> myLoanList(PageVo vo);
	
	@Select("select sum(p.amount) from p2p_loan_info p where p.uid =#{userId} and p.status>=21")
	Long getTotoalBorrow(Integer userId);
	
	@Select("select count(*)from p2p_loan_info p where p.uid =#{userId} and p.status>=32")
	int getSucceedTime(Integer userId);
	
	@Select("select sum(repay_amount)from p2p_loan_repay p where p.uid = #{userId} and p.status=21")
	Long getBackBenxi(Integer userId);
	
	@Select("select count(*)from p2p_loan_repay p where p.uid = #{userId} and p.status=21")
	Integer getNormalBackTime(Integer userId);
	
	@Select("select sum(repay_amount)from p2p_loan_repay p where p.uid = #{userId} and p.status=11")
	Long getToBackBenxi(Integer userId);
	
	@Select("select sum(loan_fee) from p2p_loan_repay p where p.uid =#{userId} and p.status=11")
	Long getTobackManagefee(Integer userId);
	
	@Select("select count(loan_fee)from p2p_loan_repay p where p.uid = #{userId} and p.status = 31")
	int getPlatBackTime(Integer userId);
	
	@Select("select count(*)from p2p_loan_repay p where p.uid = #{userId} and p.status=11")
	int getGoingBackTime(Integer userId);
	
	@Select("select count(*) from p2p_loan_info p where p.uid=#{userId}")
	int userExistInp2ploaninfo(Integer userID);
	
	@Select("select count(*) from p2p_loan_repay p where p.uid=#{userId}")
	int userExistInp2ploanrepay(Integer userID);
}
